package inits

import (
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
	"log"
	"rpc-server/basic/global"
)

func InitMysql() {
	var err error
	// 参考 https://github.com/go-sql-driver/mysql#dsn-data-source-name 获取详情
	dsn := "root:cd423a2933d92b70@tcp(14.103.168.20:3306)/tiktok?charset=utf8mb4&parseTime=True&loc=Local"
	global.DB, err = gorm.Open(mysql.Open(dsn), &gorm.Config{})
	if err != nil {
		panic(err)
		return
	}

	log.Println("mysql连接成功")
}
